package com.dlc.felear.xiaoensale.utils;

import android.content.Context;
import android.util.Log;

public class RestartOsUtil {
    private static final String TAG = "RestartOsUtil";
    public static final int NO_NET = 1;
    public static final int HAS_NET = 0;
    private Context context;
    private static RestartOsUtil instance;
    private int flag = 0;

    public static RestartOsUtil getInstance(Context context) {
        if (instance == null) {
            synchronized (RestartOsUtil.class) {
                if (instance == null) {
                    instance = new RestartOsUtil(context);
                }
            }
        }
        return instance;
    }

    public void recordFlag(int a) {
        if (a == NO_NET) {
            Log.e(TAG, "没有网络");
            flag++;
        } else {
            Log.e(TAG, "有网络");
            flag = 0;
        }
        if (flag > 2) {
            reStartOs();
            flag = 0;
        }

    }

    public RestartOsUtil(Context context) {
        this.context = context;
    }

    private void reStartOs() {
        Log.e(TAG, "重启Os");
//            OsUtil.reStartOs();
    }
}
